package msg

import (
	"context"
	"github.com/apache/rocketmq-client-go/v2/primitive"
	"github.com/zeromicro/go-zero/core/logx"
	"go-zero-project/services/user/api/internal/svc"
)

type ConsumerMsgLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewConsumerMsgLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ConsumerMsgLogic {
	return &ConsumerMsgLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (c *ConsumerMsgLogic) ConsumerMsg(messageExt *primitive.MessageExt) {
	// 调用自己的业务 根据topic 分发自己的业务
	logx.Infof("消费消息 callback: topic:%s ,messageId:%s msg:%s\n", messageExt.Topic,
		messageExt.MsgId, string(messageExt.Body))
}
